package de.au.fi.controller;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import de.au.fi.calc.CalcHelper;
import de.au.fi.domain.Stock.AnalystenMeinung;
import de.au.fi.domain.Stock.CapType;
import de.au.fi.domain.Stock.DreimonatsReversal;


@Component
@Scope("application")
public class HelperController 
{
	public Double getDoubleCeiled(Object object)
	{
		try {
			return CalcHelper.roundToTwoDigits((Double)object);
		} catch (Exception e) {
		}
		return null;
	}
	
	public String substring(String string, int nrOfChars)
	{
		if(string == null || string.isEmpty())return string;
		if(string.length() <= nrOfChars)return string;
		return string.substring(0, nrOfChars-1);
	}
	
	public Object[] getDreiMonatsReversals()
	{
		return DreimonatsReversal.values();
	}
	
	public Object[] getCapTypes()
	{
		return CapType.values();
	}
	
	public Object[] getAnalystenMeinungen()
	{
		return AnalystenMeinung.values();
	}
}
